<?php
declare (strict_types = 1);

namespace app\services;

use app\model\admin;
use app\services\JWTService;
/**
 * @mixin \think\Model
 */
class AdminService 
{
    public static function checkAdmin(array $where){
        $userInfo = admin::where($where)->findOrEmpty();
        if($userInfo){
            //保存token
            $token = JWTService::encode($userInfo);
            $token = 'Bearer '.$token;
            return ['code'=>1,'msg'=>'登录成功','data'=>['token'=>$token]];
        }else{
            return ['code'=>0,'msg'=>'登录失败'];
        }
    }
}
